home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Developer / Include / C / xpk / xpk.h next >
Encoding:
C/C++ Source or Header  |  1997-05-15  |  15.0 KB  |  360 lines

  1. #ifndef XPK_XPK_H
  2. #define XPK_XPK_H
  3.  
  4. /*
  5. **    $VER: xpk/xpk.h 4.10 (05.04.97) by SDI
  6. **
  7. **    (C) Copyright 1991-1996 by 
  8. **          Urban Dominik Mueller, Bryan Ford,
  9. **          Christian Schneider, Christian von Roques,
  10. **        Dirk Stöcker
  11. **        All Rights Reserved
  12. */
  13.  
  14. #ifndef EXEC_LIBRARIES_H
  15.   #include <exec/libraries.h>
  16. #endif
  17.  
  18. #ifndef EXEC_LISTS_H
  19.   #include <exec/lists.h>
  20. #endif
  21.  
  22. #ifndef UTILITY_TAGITEM_H
  23.   #include <utility/tagitem.h>
  24. #endif
  25.  
  26. #ifndef UTILITY_HOOKS_H
  27.   #include <utility/hooks.h>
  28. #endif
  29.  
  30. #define XPKNAME "xpkmaster.library"
  31.  
  32. /***************************************************************************
  33.  *
  34.  *
  35.  *      The packing/unpacking tags
  36.  *
  37.  * (TRUE) or (FALSE) mean the default value given by xpkmaster.library
  38.  *
  39.  */
  40.  
  41. #define XPK_TagBase    (TAG_USER + ('X'<<8) + 'P')
  42. #define XTAG(a)        (XPK_TagBase+a)
  43.  
  44. /* Caller must supply ONE of these to tell Xpk#?ack where to get data from */
  45. #define XPK_InName      XTAG(0x01) /* Process an entire named file */
  46. #define XPK_InFH      XTAG(0x02) /* File handle - start from current position */
  47.                      /* If packing partial file, must also supply InLen */
  48. #define XPK_InBuf      XTAG(0x03) /* Single unblocked memory buffer */
  49.                      /* Must also supply InLen */
  50. #define XPK_InHook      XTAG(0x04) /* Call custom Hook to read data */
  51.                      /* Must also supply InLen, when hook
  52.                         cannot do! (not for XPK unpacking) */
  53.  
  54. /* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to */
  55. #define XPK_OutName      XTAG(0x10) /* Write (or overwrite) this data file */
  56. #define XPK_OutFH      XTAG(0x11) /* File handle - write from current position on */
  57. #define XPK_OutBuf      XTAG(0x12) /* Unblocked buffer - must also supply OutBufLen */
  58. #define XPK_GetOutBuf      XTAG(0x13) /* Master allocates OutBuf - ti_Data points to buf ptr */
  59. #define XPK_OutHook      XTAG(0x14) /* Callback Hook to get output buffers */
  60.  
  61. /* Other tags for Pack/Unpack */
  62. #define XPK_InLen      XTAG(0x20) /* Length of data in input buffer  */
  63. #define XPK_OutBufLen      XTAG(0x21) /* Length of output buffer         */
  64. #define XPK_GetOutLen      XTAG(0x22) /* ti_Data points to long to receive OutLen    */
  65. #define XPK_GetOutBufLen  XTAG(0x23) /* ti_Data points to long to receive OutBufLen */
  66. #define XPK_Password      XTAG(0x24) /* Password for de/encoding        */
  67. #define XPK_GetError      XTAG(0x25) /* ti_Data points to buffer for error message  */
  68. #define XPK_OutMemType      XTAG(0x26) /* Memory type for output buffer   */
  69. #define XPK_PassThru      XTAG(0x27) /* Bool: Pass through unrecognized formats on unpack */
  70. #define XPK_StepDown      XTAG(0x28) /* Bool: Step down pack method if necessary    */
  71. #define XPK_ChunkHook      XTAG(0x29) /* Call this Hook between chunks   */
  72. #define XPK_PackMethod      XTAG(0x2a) /* Do a FindMethod before packing  */
  73. #define XPK_ChunkSize      XTAG(0x2b) /* Chunk size to try to pack with  */
  74. #define XPK_PackMode      XTAG(0x2c) /* Packing mode for sublib to use  */
  75. #define XPK_NoClobber      XTAG(0x2d) /* Don't overwrite existing files  */
  76. #define XPK_Ignore      XTAG(0x2e) /* Skip this tag                   */
  77. #define XPK_TaskPri      XTAG(0x2f) /* Change priority for (un)packing */
  78. #define XPK_FileName      XTAG(0x30) /* File name for progress report   */
  79. #define XPK_ShortError      XTAG(0x31) /* !!! obsolete !!!                */
  80. #define XPK_PackersQuery  XTAG(0x32) /* Query available packers         */
  81. #define XPK_PackerQuery      XTAG(0x33) /* Query properties of a packer    */
  82. #define XPK_ModeQuery      XTAG(0x34) /* Query properties of packmode    */
  83. #define XPK_LossyOK      XTAG(0x35) /* Lossy packing permitted? (FALSE)*/
  84. #define XPK_NoCRC         XTAG(0x36) /* Ignore checksum                 */
  85.  
  86. /* preference depending tags added for version 4 - their default value
  87.  may depend on preferences, see <xpk/xpkprefs.h> for more info */
  88.  
  89. #define XPK_UseXfdMaster  XTAG(0x40) /* Use xfdmaster.library (FALSE)   */
  90. #define XPK_UseExternals  XTAG(0x41) /* Use packers in extern dir (TRUE)*/
  91. #define XPK_PassRequest   XTAG(0x42) /* automatic password req.? (FALSE)*/
  92. #define XPK_Preferences   XTAG(0x43) /* use prefs semaphore ? (TRUE)    */
  93. #define XPK_ChunkReport      XTAG(0x44) /* automatic chunk report ? (FALSE)*/
  94.  
  95. /* tags XTAG(0x50) to XTAG(0x69) are for XpkPassRequest -- see below */
  96.  
  97. #define XPK_MARGIN    256    /* Safety margin for output buffer    */
  98.  
  99. /***************************************************************************
  100.  *
  101.  *
  102.  *     The hook function interface
  103.  *
  104.  */
  105.  
  106. /* Message passed to InHook and OutHook as the ParamPacket */
  107. struct XpkIOMsg {
  108.     ULONG xiom_Type        ; /* Read/Write/Alloc/Free/Abort    */
  109.     APTR  xiom_Ptr        ; /* The mem area to read from/write to */
  110.     LONG  xiom_Size        ; /* The size of the read/write        */
  111.     ULONG xiom_IOError    ; /* The IoErr() that occurred        */
  112.     ULONG xiom_Reserved    ; /* Reserved for future use        */
  113.     ULONG xiom_Private1    ; /* Hook specific, will be set to 0 by */
  114.     ULONG xiom_Private2    ; /* master library before first use    */
  115.     ULONG xiom_Private3    ;
  116.     ULONG xiom_Private4    ;
  117. };
  118.  
  119. /* The values for XpkIoMsg->Type */
  120. #define XIO_READ    1
  121. #define XIO_WRITE   2
  122. #define XIO_FREE    3
  123. #define XIO_ABORT   4
  124. #define XIO_GETBUF  5
  125. #define XIO_SEEK    6
  126. #define XIO_TOTSIZE 7
  127.  
  128. /***************************************************************************
  129.  *
  130.  *
  131.  *      The progress report interface
  132.  *
  133.  */
  134.  
  135. /* Passed to ChunkHook as the ParamPacket */
  136. struct XpkProgress {
  137.   ULONG     xp_Type;        /* Type of report: start/cont/end/abort      */
  138.   STRPTR xp_PackerName;     /* Brief name of packer being used           */
  139.   STRPTR xp_PackerLongName; /* Descriptive name of packer being used       */
  140.   STRPTR xp_Activity;       /* Packing/unpacking message          */
  141.   STRPTR xp_FileName;       /* Name of file being processed, if available */
  142.   ULONG     xp_CCur;           /* Amount of packed data already processed      */
  143.   ULONG     xp_UCur;           /* Amount of unpacked data already processed  */
  144.   ULONG     xp_ULen;        /* Amount of unpacked data in file          */
  145.   LONG     xp_CF;            /* Compression factor so far          */
  146.   ULONG     xp_Done;           /* Percentage done already              */
  147.   ULONG     xp_Speed;          /* Bytes per second, from beginning of stream */
  148.   ULONG     xp_Reserved[8];    /* For future use                  */
  149. };
  150. #define XPKPROG_START    1
  151. #define XPKPROG_MID    2
  152. #define XPKPROG_END    3
  153.  
  154. /***************************************************************************
  155.  *
  156.  *
  157.  *       The file info block
  158.  *
  159.  */
  160.  
  161. struct XpkFib {
  162.     ULONG    xf_Type        ; /* Unpacked, packed, archive?   */
  163.     ULONG    xf_ULen        ; /* Uncompressed length          */
  164.     ULONG    xf_CLen        ; /* Compressed length            */
  165.     ULONG    xf_NLen        ; /* Next chunk len               */
  166.     ULONG    xf_UCur        ; /* Uncompressed bytes so far    */
  167.     ULONG    xf_CCur        ; /* Compressed bytes so far      */
  168.     ULONG    xf_ID        ; /* 4 letter ID of packer        */
  169.     UBYTE    xf_Packer[6]    ; /* 4 letter name of packer      */
  170.     UWORD    xf_SubVersion    ; /* Required sublib version      */
  171.     UWORD    xf_MasVersion    ; /* Required masterlib version   */
  172.     ULONG    xf_Flags    ; /* Password?                    */
  173.     UBYTE    xf_Head[16]    ; /* First 16 bytes of orig. file */
  174.     LONG    xf_Ratio    ; /* Compression ratio            */
  175.     ULONG    xf_Reserved[8]    ; /* For future use               */
  176. };
  177.  
  178. #define XPKTYPE_UNPACKED 0        /* Not packed                   */
  179. #define XPKTYPE_PACKED   1        /* Packed file                  */
  180. #define XPKTYPE_ARCHIVE  2        /* Archive                      */
  181.  
  182. #define XPKFLAGS_PASSWORD 1       /* Password needed              */
  183. #define XPKFLAGS_NOSEEK   2       /* Chunks are dependent         */
  184. #define XPKFLAGS_NONSTD   4       /* Nonstandard file format      */
  185.  
  186. /***************************************************************************
  187.  *
  188.  *
  189.  *       The error messages
  190.  *
  191.  */
  192.  
  193. #define XPKERR_OK      0
  194. #define XPKERR_NOFUNC       -1    /* This function not implemented    */
  195. #define XPKERR_NOFILES       -2    /* No files allowed for this function    */
  196. #define XPKERR_IOERRIN       -3    /* Input error happened            */
  197. #define XPKERR_IOERROUT       -4    /* Output error happened        */
  198. #define XPKERR_CHECKSUM       -5    /* Check sum test failed        */
  199. #define XPKERR_VERSION       -6    /* Packed file's version newer than lib */
  200. #define XPKERR_NOMEM       -7    /* Out of memory            */
  201. #define XPKERR_LIBINUSE       -8    /* For not-reentrant libraries        */
  202. #define XPKERR_WRONGFORM   -9    /* Was not packed with this library    */
  203. #define XPKERR_SMALLBUF       -10    /* Output buffer too small        */
  204. #define XPKERR_LARGEBUF       -11    /* Input buffer too large        */
  205. #define XPKERR_WRONGMODE   -12    /* This packing mode not supported    */
  206. #define XPKERR_NEEDPASSWD  -13    /* Password needed for decoding        */
  207. #define XPKERR_CORRUPTPKD  -14    /* Packed file is corrupt        */
  208. #define XPKERR_MISSINGLIB  -15    /* Required library is missing        */
  209. #define XPKERR_BADPARAMS   -16    /* Caller's TagList was screwed up    */
  210. #define XPKERR_EXPANSION   -17    /* Would have caused data expansion    */
  211. #define XPKERR_NOMETHOD    -18    /* Cannot find requested method        */
  212. #define XPKERR_ABORTED     -19    /* Operation aborted by user        */
  213. #define XPKERR_TRUNCATED   -20    /* Input file is truncated        */
  214. #define XPKERR_WRONGCPU    -21    /* Better CPU required for this library    */
  215. #define XPKERR_PACKED      -22    /* Data are already XPacked        */
  216. #define XPKERR_NOTPACKED   -23    /* Data not packed            */
  217. #define XPKERR_FILEEXISTS  -24    /* File already exists            */
  218. #define XPKERR_OLDMASTLIB  -25    /* Master library too old        */
  219. #define XPKERR_OLDSUBLIB   -26    /* Sub library too old            */
  220. #define XPKERR_NOCRYPT     -27    /* Cannot encrypt            */
  221. #define XPKERR_NOINFO      -28    /* Can't get info on that packer    */
  222. #define XPKERR_LOSSY       -29    /* This compression method is lossy    */
  223. #define XPKERR_NOHARDWARE  -30    /* Compression hardware required    */
  224. #define XPKERR_BADHARDWARE -31    /* Compression hardware failed        */
  225. #define XPKERR_WRONGPW     -32    /* Password was wrong            */
  226. #define XPKERR_UNKNOWN       -33    /* unknown error cause            */
  227.  
  228. #define XPKERRMSGSIZE    80    /* Maximum size of an error message    */
  229.  
  230. /***************************************************************************
  231.  *
  232.  *
  233.  *     The XpkQuery() call
  234.  *
  235.  */
  236.  
  237. struct XpkPackerInfo {
  238.     UBYTE    xpi_Name[24]       ; /* Brief name of the packer          */
  239.     UBYTE    xpi_LongName[32]   ; /* Full name of the packer           */
  240.     UBYTE    xpi_Description[80]; /* One line description of packer    */
  241.     ULONG    xpi_Flags          ; /* Defined below                     */
  242.     ULONG    xpi_MaxChunk       ; /* Max input chunk size for packing  */
  243.     ULONG    xpi_DefChunk       ; /* Default packing chunk size        */
  244.     UWORD    xpi_DefMode        ; /* Default mode on 0..100 scale      */
  245. };
  246.  
  247. /* Defines for Flags */
  248. #define XPKIF_PK_CHUNK   0x00001 /* Library supplies chunk packing       */
  249. #define XPKIF_PK_STREAM  0x00002 /* Library supplies stream packing      */
  250. #define XPKIF_PK_ARCHIVE 0x00004 /* Library supplies archive packing     */
  251. #define XPKIF_UP_CHUNK   0x00008 /* Library supplies chunk unpacking     */
  252. #define XPKIF_UP_STREAM  0x00010 /* Library supplies stream unpacking    */
  253. #define XPKIF_UP_ARCHIVE 0x00020 /* Library supplies archive unpacking   */
  254. #define XPKIF_HOOKIO     0x00080 /* Uses full Hook I/O                   */
  255. #define XPKIF_CHECKING   0x00400 /* Does its own data checking           */
  256. #define XPKIF_PREREADHDR 0x00800 /* Unpacker pre-reads the next chunkhdr */
  257. #define XPKIF_ENCRYPTION 0x02000 /* Sub library supports encryption      */
  258. #define XPKIF_NEEDPASSWD 0x04000 /* Sub library requires encryption      */
  259. #define XPKIF_MODES      0x08000 /* Sub library has different modes      */
  260. #define XPKIF_LOSSY      0x10000 /* Sub library does lossy compression   */
  261.  
  262. struct XpkMode {
  263.   struct XpkMode *xm_Next;   /* Chain to next descriptor for ModeDesc list*/
  264.   ULONG   xm_Upto;         /* Maximum efficiency handled by this mode   */
  265.   ULONG   xm_Flags;         /* Defined below                             */
  266.   ULONG   xm_PackMemory;     /* Extra memory required during packing      */
  267.   ULONG   xm_UnpackMemory;   /* Extra memory during unpacking             */
  268.   ULONG   xm_PackSpeed;      /* Approx packing speed in K per second      */
  269.   ULONG   xm_UnpackSpeed;    /* Approx unpacking speed in K per second    */
  270.   UWORD   xm_Ratio;         /* CF in 0.1% for AmigaVision executable     */
  271.   UWORD   xm_ChunkSize;         /* Desired chunk size in K (!!) for this mode*/
  272.   UBYTE   xm_Description[10];/* 7 character mode description              */
  273. };
  274.  
  275. /* Defines for XpkMode.Flags */
  276. #define XPKMF_A3000SPEED 0x00000001 /* Timings on A3000/25                */
  277. #define XPKMF_PK_NOCPU   0x00000002 /* Packing not heavily CPU dependent  */
  278. #define XPKMF_UP_NOCPU   0x00000004 /* Unpacking... (i.e. hardware modes) */
  279.  
  280. #define MAXPACKERS 100
  281.  
  282. struct XpkPackerList {
  283.     ULONG    xpl_NumPackers;
  284.     UBYTE    xpl_Packer[MAXPACKERS][6];
  285. };
  286.  
  287. /***************************************************************************
  288.  *
  289.  *
  290.  *     The XpkOpen() type calls
  291.  *
  292.  */
  293.  
  294. #define XPKLEN_ONECHUNK 0x7fffffff
  295.  
  296. /***************************************************************************
  297.  *
  298.  *
  299.  *     The XpkPassRequest() call (library version 4)
  300.  *
  301.  */
  302.  
  303. #define XPK_PassChars    XTAG(0x50) /* which chars should be used */
  304. #define XPK_PasswordBuf XTAG(0x51) /* buffer to write password to */
  305. #define XPK_PassBufSize XTAG(0x52) /* size of password buffer */
  306. #define XPK_Key16BitPtr    XTAG(0x53) /* pointer to UWORD var for key data */
  307. #define XPK_Key32BitPtr    XTAG(0x54) /* pointer to ULONG var for key data */
  308. #define XPK_PubScreen    XTAG(0x55) /* pointer to struct Screen */
  309. #define XPK_PassTitle    XTAG(0x56) /* Text shown in Screen title */
  310. #define XPK_TimeOut    XTAG(0x57) /* Timeout time of requester in seconds */
  311.  
  312. /* XPKPASSFF defines for XPK_PassChars. Do not use. Use XPKPASSFLG defines */
  313.  
  314. #define XPKPASSFF_30x39        (1 << 0)    /* all numbers        */
  315. #define XPKPASSFF_41x46        (1 << 1)    /* chars 'A' to 'F'    */
  316. #define XPKPASSFF_61x66        (1 << 2)    /* chars 'a' to 'f'    */
  317. #define XPKPASSFF_47x5A        (1 << 3)    /* chars 'G' to 'Z'    */
  318. #define XPKPASSFF_67x7A        (1 << 4)    /* chars 'g' to 'z'    */
  319. #define XPKPASSFF_20        (1 << 5)    /* space character    */
  320. #define XPKPASSFF_SPECIAL7BIT    (1 << 6)
  321.  /* all chars 0x20 to 0x7F without above defined */
  322. #define XPKPASSFF_C0xDE        (1 << 7)    /* upper special chars    */
  323. #define XPKPASSFF_DFxFF        (1 << 8)    /* lower special chars    */
  324. #define XPKPASSFF_SPECIAL8BIT    (1 << 9)    /* special 8Bit chars    */
  325.  
  326. /* flags for XPK_PassChars, XPKPASSFLG_PRINTABLE is default */
  327.  
  328. /*
  329. NUMERIC        : numbers
  330. HEXADECIMAL    : hex numbers
  331. ALPHANUMERIC    : numbers and letters
  332. INTALPHANUM    : numbers and international letters
  333. ASCII7        : 7 Bit ASCII
  334. PRINTABLE    : all characters
  335. */
  336.  
  337. #define XPKPASSFLG_NUMERIC    XPKPASSFF_30x39
  338. #define XPKPASSFLG_HEXADECIMAL    (XPKPASSFF_30x39|XPKPASSFF_41x46|XPKPASSFF_61x66)
  339. #define XPKPASSFLG_ALPHANUMERIC    (XPKPASSFLG_HEXADECIMAL|XPKPASSFF_47x5A|XPKPASSFF_67x7A)
  340. #define XPKPASSFLG_INTALPHANUM    (XPKPASSFLG_ALPHANUMERIC|XPKPASSFF_C0xDE|XPKPASSFF_DFxFF)
  341. #define XPKPASSFLG_ASCII7    (XPKPASSFLG_ALPHANUMERIC|XPKPASSFF_SPECIAL7BIT)
  342. #define XPKPASSFLG_PRINTABLE    (XPKPASSFLG_INTALPHANUM|XPKPASSFF_SPECIAL7BIT|XPKPASSFF_SPECIAL8BIT|XPKPASSFF_20)
  343.  
  344. /***************************************************************************
  345.  *
  346.  *
  347.  *     The XpkAllocObject() call (library version 4)
  348.  *
  349.  * use this always with library version >= 4, do NO longer allocate the
  350.  * structures yourself
  351.  *
  352.  */
  353.  
  354. #define XPKOBJ_FIB        0    /* XpkFib structure */
  355. #define XPKOBJ_PACKERINFO    1    /* XpkPackerInfo structure */
  356. #define XPKOBJ_MODE        2    /* XpkMode structure */
  357. #define XPKOBJ_PACKERLIST    3    /* XpkPackerList structure */
  358.  
  359. #endif /* XPK_XPK_H */
  360.